/* eslint valid-jsdoc: "off" */

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_naonao';

  // add your middleware config here
  config.middleware = ['jurisdictionHandler', 'errorHandler'];

  // cluster configuration
  config.cluster = {
    listen: {
      port: 7001,
      hostname: '127.0.0.1',
    },
  };

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
    verification_mode: 'jwt',
    jwt_exp: 60 * 10, // jwt过期时间(秒)
    jwt_refresh_exp: 60 * 60 * 24 * 15, // refreshToken过期时间(秒)
  };
  config.session = {
    maxAge: 24 * 3600 * 1000, // ms
    // maxAge: 20 * 1000, // ms
    key: 'EGG_SESS',
    httpOnly: true,
    signed: false,
    encrypt: false,
    renew: true,
    // sameSite: null,
  };
  config.jwt = {
    secret: 'Great4-M',
    secret_refresh: 'Great4-M-refresh',
    enable: true, // default is false
    match: '/jwt', // optional
  };
  // sequelize配置
  config.sequelize = {
    dialect: 'mysql',
    host: '127.0.0.1',
    port: 3306,
    database: 'nn_node',
    username: 'root',
    password: '302108jw302',
    timezone: '+08:00',
    define: {
      raw: false,
      underscored: false,
      charset: 'utf8',
      timestamp: true,
      createdAt: 'created_at',
      updatedAt: 'updated_at',
      deletedAt: 'deleted_at',
    },
  };

  // swagger配置
  config.swaggerdoc = {
    dirScanner: './app/controller',
    contractScanner: './app/contract',
    apiInfo: {
      title: 'nn_node API',
      description: 'nn_node API 文档',
      version: '1.0.0',
    },
    schemes: ['http', 'https'],
    consumes: ['application/json'],
    produces: ['application/json'],
    enableSecurity: false,
    // enableValidate: true,
    routerMap: true,
    enable: true,
  };
  config.mailer = {
    host: 'smtp.qq.com',
    port: 465,
    secure: true, // true for 465, false for other ports
    auth: {
      user: '2597136902@qq.com', // generated ethereal user
      pass: 'qjhtryxwgunsdjdh', // generated ethereal password
    },
  };
  return {
    ...config,
    ...userConfig,
  };
};
